import * as THREE from 'three';

// 引入gltf加载器
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
// 实例化加载器
const loader = new GLTFLoader();

const model = new THREE.Group();

loader.load('./building.glb', function (gltf) {

    // const mesh1 = gltf.scene.getObjectByName('Cube_1');
    // mesh1.material.color.set(0xffffff);
    // console.log(mesh1);
    gltf.scene.traverse(function(obj){
        if(obj.isMesh){
            // console.log(obj.name);
            if(obj.name === 'Cube_1'){
                obj.material = new THREE.MeshBasicMaterial({
                    color: 0xffffff,
                })
                // obj.material.color.set(0xffffff);
            }
        }
    })
    model.add(gltf.scene);
})


export default model;